package com.xinxin.leetcode.problem190;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ShiXinXin
 * @date 2019-08-29 2:41
 */
public class Solution {
    // you need treat n as an unsigned value
    public int reverseBits(int n) {
        int s = 0;
        for (int i = 0; i < 32; i++) {
            s = (s << 1) + (n & 1);
            n >>>= 1;
        }
        return s;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().reverseBits(-3));
    }
}
